package com.demo2do.fms.entity.supplier.common;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;

/**
 * 服务供方停车场资源
 * 
 * 与supplier关联关系:多对一
 * 
 * Created by zhonghui on 2017/7/11.
 */
@Entity
@Table(name = "FMS_SUPPLIER_PARKING_RESOURCE")
public class SupplierParkingResource {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;

    /** 所属supplier */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @PersistentFormat
    private Supplier supplier;

    /** 位置 */
    private String position;

    /** 面积 */
    private BigDecimal area;

    /** 场地来源(没有原始数据) */
    @Enumerated(EnumType.ORDINAL)
    private FieldSource fieldSource;

    /** 到期日期 */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date expireDate;

    @Column(name = "IS_DISABLED")
    private Boolean disabled;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Column(name = "CREATOR")
    private Long creator;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModifyTime;

    @Column(name = "LAST_OPERATOR")
    private Long lastOperator;

    /**
     * Instantiates a new Supplier parking resource.
     */
    public SupplierParkingResource() {
    }
    
    /**
     * 
     * @param supplier
     */
    public SupplierParkingResource(Supplier supplier) {
        this.supplier = supplier;
    }
    
    /**
     * 
     * @return
     */
    public SupplierParkingResource create () {
        
        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.creator=new Long(1);
        this.lastOperator = this.creator;
        this.disabled = false;
        
        return this;
    }
    
    /**
     * 
     * @return
     */
    public SupplierParkingResource edit () {
        
        this.lastModifyTime = new Date();
        this.lastOperator = new Long(1);
        
        return this;
    }
    /**
     * 
     * @return
     */
    public SupplierParkingResource delete () {
        
        this.disabled = true;
        this.lastModifyTime = new Date();
        
        return this;
        
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the supplier
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * @return the position
     */
    public String getPosition() {
        return position;
    }

    /**
     * @return the area
     */
    public BigDecimal getArea() {
        return area;
    }

    /**
     * @return the fieldSource
     */
    public FieldSource getFieldSource() {
        return fieldSource;
    }

    /**
     * @return the expireDate
     */
    public Date getExpireDate() {
        return expireDate;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param supplier the supplier to set
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * @param position the position to set
     */
    public void setPosition(String position) {
        this.position = position;
    }

    /**
     * @param area the area to set
     */
    public void setArea(BigDecimal area) {
        this.area = area;
    }

    /**
     * @param fieldSource the fieldSource to set
     */
    public void setFieldSource(FieldSource fieldSource) {
        this.fieldSource = fieldSource;
    }

    /**
     * @param expireDate the expireDate to set
     */
    public void setExpireDate(Date expireDate) {
        this.expireDate = expireDate;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param creator the creator to set
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }
}
